<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
-----------------------------------------------------------------------------
--
-- (c) The University of Glasgow 2001-2003
--
-- Access to system tools: gcc, cp, rm etc
--
-----------------------------------------------------------------------------
-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# LANGUAGE CPP, MultiWayIf, ScopedTypeVariables #-}</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.SysTools</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Initialisation</span></span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#initSysTools"><span class="hs-identifier">initSysTools</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#lazyInitLlvmConfig"><span class="hs-identifier">lazyInitLlvmConfig</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Interface to system tools</span></span><span>
</span><span id="line-19"></span><span>        </span><span class="hs-keyword">module</span><span> </span><span class="annot"><a href="GHC.SysTools.Tasks.html"><span class="hs-identifier">GHC.SysTools.Tasks</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="hs-keyword">module</span><span> </span><span class="annot"><a href="GHC.SysTools.Info.html"><span class="hs-identifier">GHC.SysTools.Info</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#linkDynLib"><span class="hs-identifier">linkDynLib</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#copy"><span class="hs-identifier">copy</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#copyWithHeader"><span class="hs-identifier">copyWithHeader</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><span class="hs-comment">-- * General utilities</span></span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier">Option</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="../../ghc-boot/src/GHC.BaseDir.html#expandTopDir"><span class="hs-identifier">expandTopDir</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Platform-specifics</span></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#libmLinkOpts"><span class="hs-identifier">libmLinkOpts</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Mac OS X frameworks</span></span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#getUnitFrameworkOpts"><span class="hs-identifier">getUnitFrameworkOpts</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="GHC.SysTools.html#getFrameworkOpts"><span class="hs-identifier">getFrameworkOpts</span></a></span><span>
</span><span id="line-37"></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Settings.Utils.html#"><span class="hs-identifier">GHC.Settings.Utils</span></a></span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.html"><span class="hs-identifier">GHC.Unit</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Ways.html"><span class="hs-identifier">GHC.Driver.Ways</span></a></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Except.html#"><span class="hs-identifier">Control.Monad.Trans.Except</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Except.html#runExceptT"><span class="hs-identifier">runExceptT</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.html#"><span class="hs-identifier">System.FilePath</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Unsafe.html#"><span class="hs-identifier">System.IO.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Unsafe.html#unsafeInterleaveIO"><span class="hs-identifier">unsafeInterleaveIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.SysTools.ExtraObj.html"><span class="hs-identifier">GHC.SysTools.ExtraObj</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.SysTools.Info.html"><span class="hs-identifier">GHC.SysTools.Info</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.SysTools.Tasks.html"><span class="hs-identifier">GHC.SysTools.Tasks</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.SysTools.BaseDir.html"><span class="hs-identifier">GHC.SysTools.BaseDir</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Settings.IO.html"><span class="hs-identifier">GHC.Settings.IO</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-comment">{-
Note [How GHC finds toolchain utilities]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GHC.SysTools.initSysProgs figures out exactly where all the auxiliary programs
are, and initialises mutable variables to make it easy to call them.
To do this, it makes use of definitions in Config.hs, which is a Haskell
file containing variables whose value is figured out by the build system.

Config.hs contains two sorts of things

  cGCC,         The *names* of the programs
  cCPP            e.g.  cGCC = gcc
  cUNLIT                cCPP = gcc -E
  etc           They do *not* include paths


  cUNLIT_DIR   The *path* to the directory containing unlit, split etc
  cSPLIT_DIR   *relative* to the root of the build tree,
                   for use when running *in-place* in a build tree (only)


---------------------------------------------
NOTES for an ALTERNATIVE scheme (i.e *not* what is currently implemented):

Another hair-brained scheme for simplifying the current tool location
nightmare in GHC: Simon originally suggested using another
configuration file along the lines of GCC's specs file - which is fine
except that it means adding code to read yet another configuration
file.  What I didn't notice is that the current package.conf is
general enough to do this:

Package
    {name = &quot;tools&quot;,    import_dirs = [],  source_dirs = [],
     library_dirs = [], hs_libraries = [], extra_libraries = [],
     include_dirs = [], c_includes = [],   package_deps = [],
     extra_ghc_opts = [&quot;-pgmc/usr/bin/gcc&quot;,&quot;-pgml${topdir}/bin/unlit&quot;, ... etc.],
     extra_cc_opts = [], extra_ld_opts = []}

Which would have the advantage that we get to collect together in one
place the path-specific package stuff with the path-specific tool
stuff.
                End of NOTES
---------------------------------------------

************************************************************************
*                                                                      *
\subsection{Initialisation}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-comment">-- Note [LLVM configuration]</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- The `llvm-targets` and `llvm-passes` files are shipped with GHC and contain</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- information needed by the LLVM backend to invoke `llc` and `opt`.</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- Specifically:</span><span>
</span><span id="line-120"></span><span class="hs-comment">--</span><span>
</span><span id="line-121"></span><span class="hs-comment">--  * llvm-targets maps autoconf host triples to the corresponding LLVM</span><span>
</span><span id="line-122"></span><span class="hs-comment">--    `data-layout` declarations. This information is extracted from clang using</span><span>
</span><span id="line-123"></span><span class="hs-comment">--    the script in utils/llvm-targets/gen-data-layout.sh and should be updated</span><span>
</span><span id="line-124"></span><span class="hs-comment">--    whenever we target a new version of LLVM.</span><span>
</span><span id="line-125"></span><span class="hs-comment">--</span><span>
</span><span id="line-126"></span><span class="hs-comment">--  * llvm-passes maps GHC optimization levels to sets of LLVM optimization</span><span>
</span><span id="line-127"></span><span class="hs-comment">--    flags that GHC should pass to `opt`.</span><span>
</span><span id="line-128"></span><span class="hs-comment">--</span><span>
</span><span id="line-129"></span><span class="hs-comment">-- This information is contained in files rather the GHC source to allow users</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- to add new targets to GHC without having to recompile the compiler.</span><span>
</span><span id="line-131"></span><span class="hs-comment">--</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- Since this information is only needed by the LLVM backend we load it lazily</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- with unsafeInterleaveIO. Consequently it is important that we lazily pattern</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- match on LlvmConfig until we actually need its contents.</span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span class="annot"><a href="GHC.SysTools.html#lazyInitLlvmConfig"><span class="hs-identifier hs-type">lazyInitLlvmConfig</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-137"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#LlvmConfig"><span class="hs-identifier hs-type">LlvmConfig</span></a></span><span>
</span><span id="line-138"></span><span id="lazyInitLlvmConfig"><span class="annot"><span class="annottext">lazyInitLlvmConfig :: String -&gt; IO LlvmConfig
</span><a href="GHC.SysTools.html#lazyInitLlvmConfig"><span class="hs-identifier hs-var hs-var">lazyInitLlvmConfig</span></a></span></span><span> </span><span id="local-6989586621681012939"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012939"><span class="hs-identifier hs-var">top_dir</span></a></span></span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO LlvmConfig -&gt; IO LlvmConfig
forall a. IO a -&gt; IO a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeInterleaveIO"><span class="hs-identifier hs-var">unsafeInterleaveIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO LlvmConfig -&gt; IO LlvmConfig) -&gt; IO LlvmConfig -&gt; IO LlvmConfig
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="hs-comment">-- see Note [LLVM configuration]</span><span>
</span><span id="line-140"></span><span>      </span><span id="local-6989586621681012938"><span class="annot"><span class="annottext">[(String, LlvmTarget)]
</span><a href="#local-6989586621681012938"><span class="hs-identifier hs-var">targets</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; ((String, String, String) -&gt; LlvmTarget)
-&gt; IO [(String, LlvmTarget)]
forall {f :: * -&gt; *} {f :: * -&gt; *} {a} {b}.
(Read (f (f a)), Functor f, Functor f) =&gt;
String -&gt; (a -&gt; b) -&gt; IO (f (f b))
</span><a href="#local-6989586621681012937"><span class="hs-identifier hs-var">readAndParse</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;llvm-targets&quot;</span></span><span> </span><span class="annot"><span class="annottext">(String, String, String) -&gt; LlvmTarget
</span><a href="#local-6989586621681012936"><span class="hs-identifier hs-var">mkLlvmTarget</span></a></span><span>
</span><span id="line-141"></span><span>      </span><span id="local-6989586621681012935"><span class="annot"><span class="annottext">[(Int, String)]
</span><a href="#local-6989586621681012935"><span class="hs-identifier hs-var">passes</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; (String -&gt; String) -&gt; IO [(Int, String)]
forall {f :: * -&gt; *} {f :: * -&gt; *} {a} {b}.
(Read (f (f a)), Functor f, Functor f) =&gt;
String -&gt; (a -&gt; b) -&gt; IO (f (f b))
</span><a href="#local-6989586621681012937"><span class="hs-identifier hs-var">readAndParse</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;llvm-passes&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-142"></span><span>      </span><span class="annot"><span class="annottext">LlvmConfig -&gt; IO LlvmConfig
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(LlvmConfig -&gt; IO LlvmConfig) -&gt; LlvmConfig -&gt; IO LlvmConfig
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LlvmConfig :: [(String, LlvmTarget)] -&gt; [(Int, String)] -&gt; LlvmConfig
</span><a href="GHC.Driver.Session.html#LlvmConfig"><span class="hs-identifier hs-type">LlvmConfig</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">llvmTargets :: [(String, LlvmTarget)]
</span><a href="#local-6989586621681012932"><span class="hs-identifier hs-var">llvmTargets</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(String, LlvmTarget)]
</span><a href="#local-6989586621681012938"><span class="hs-identifier hs-var">targets</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">llvmPasses :: [(Int, String)]
</span><a href="#local-6989586621681012931"><span class="hs-identifier hs-var">llvmPasses</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Int, String)]
</span><a href="#local-6989586621681012935"><span class="hs-identifier hs-var">passes</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-143"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-144"></span><span>    </span><span id="local-6989586621681012937"><span class="annot"><span class="annottext">readAndParse :: String -&gt; (a -&gt; b) -&gt; IO (f (f b))
</span><a href="#local-6989586621681012937"><span class="hs-identifier hs-var hs-var">readAndParse</span></a></span></span><span> </span><span id="local-6989586621681012918"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012918"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681012917"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621681012917"><span class="hs-identifier hs-var">builder</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-145"></span><span>      </span><span class="hs-keyword">do</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012916"><span class="annot"><span class="annottext">llvmConfigFile :: String
</span><a href="#local-6989586621681012916"><span class="hs-identifier hs-var hs-var">llvmConfigFile</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012939"><span class="hs-identifier hs-var">top_dir</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012918"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-146"></span><span>         </span><span id="local-6989586621681012914"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012914"><span class="hs-identifier hs-var">llvmConfigStr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
</span><a href="../../base/src/System.IO.html#readFile"><span class="hs-identifier hs-var">readFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012916"><span class="hs-identifier hs-var">llvmConfigFile</span></a></span><span>
</span><span id="line-147"></span><span>         </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (f (f a))
forall a. Read a =&gt; String -&gt; Maybe a
</span><a href="../../ghc-boot/src/GHC.Settings.Utils.html#maybeReadFuzzy"><span class="hs-identifier hs-var">maybeReadFuzzy</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012914"><span class="hs-identifier hs-var">llvmConfigStr</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-148"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681012911"><span class="annot"><span class="annottext">f (f a)
</span><a href="#local-6989586621681012911"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">f (f b) -&gt; IO (f (f b))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; f a -&gt; f b
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621681012917"><span class="hs-identifier hs-var">builder</span></a></span><span> </span><span class="annot"><span class="annottext">(f a -&gt; f b) -&gt; f (f a) -&gt; f (f b)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">f (f a)
</span><a href="#local-6989586621681012911"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>           </span><span class="annot"><span class="annottext">Maybe (f (f a))
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (f (f b))
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#pgmError"><span class="hs-identifier hs-var">pgmError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Can't parse &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012916"><span class="hs-identifier hs-var">llvmConfigFile</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span>    </span><span class="annot"><a href="#local-6989586621681012936"><span class="hs-identifier hs-type">mkLlvmTarget</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#LlvmTarget"><span class="hs-identifier hs-type">LlvmTarget</span></a></span><span>
</span><span id="line-152"></span><span>    </span><span id="local-6989586621681012936"><span class="annot"><span class="annottext">mkLlvmTarget :: (String, String, String) -&gt; LlvmTarget
</span><a href="#local-6989586621681012936"><span class="hs-identifier hs-var hs-var">mkLlvmTarget</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681012907"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012907"><span class="hs-identifier hs-var">dl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681012906"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012906"><span class="hs-identifier hs-var">cpu</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681012905"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012905"><span class="hs-identifier hs-var">attrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; [String] -&gt; LlvmTarget
</span><a href="GHC.Driver.Session.html#LlvmTarget"><span class="hs-identifier hs-var">LlvmTarget</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012907"><span class="hs-identifier hs-var">dl</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012906"><span class="hs-identifier hs-var">cpu</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#words"><span class="hs-identifier hs-var">words</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012905"><span class="hs-identifier hs-var">attrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="annot"><a href="GHC.SysTools.html#initSysTools"><span class="hs-identifier hs-type">initSysTools</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>          </span><span class="hs-comment">-- TopDir path</span><span>
</span><span id="line-156"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Settings.html#Settings"><span class="hs-identifier hs-type">Settings</span></a></span><span>     </span><span class="hs-comment">-- Set all the mutable variables above, holding</span><span>
</span><span id="line-157"></span><span>                                </span><span class="hs-comment">--      (a) the system programs</span><span>
</span><span id="line-158"></span><span>                                </span><span class="hs-comment">--      (b) the package-config file</span><span>
</span><span id="line-159"></span><span>                                </span><span class="hs-comment">--      (c) the GHC usage message</span><span>
</span><span id="line-160"></span><span id="initSysTools"><span class="annot"><span class="annottext">initSysTools :: String -&gt; IO Settings
</span><a href="GHC.SysTools.html#initSysTools"><span class="hs-identifier hs-var hs-var">initSysTools</span></a></span></span><span> </span><span id="local-6989586621681012902"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012902"><span class="hs-identifier hs-var">top_dir</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-161"></span><span>  </span><span id="local-6989586621681012901"><span class="annot"><span class="annottext">Either SettingsError Settings
</span><a href="#local-6989586621681012901"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExceptT SettingsError IO Settings
-&gt; IO (Either SettingsError Settings)
forall e (m :: * -&gt; *) a. ExceptT e m a -&gt; m (Either e a)
</span><a href="../../transformers/src/Control.Monad.Trans.Except.html#runExceptT"><span class="hs-identifier hs-var">runExceptT</span></a></span><span> </span><span class="annot"><span class="annottext">(ExceptT SettingsError IO Settings
 -&gt; IO (Either SettingsError Settings))
-&gt; ExceptT SettingsError IO Settings
-&gt; IO (Either SettingsError Settings)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ExceptT SettingsError IO Settings
forall (m :: * -&gt; *).
MonadIO m =&gt;
String -&gt; ExceptT SettingsError m Settings
</span><a href="GHC.Settings.IO.html#initSettings"><span class="hs-identifier hs-var">initSettings</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012902"><span class="hs-identifier hs-var">top_dir</span></a></span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either SettingsError Settings
</span><a href="#local-6989586621681012901"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-163"></span><span>    </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681012899"><span class="annot"><span class="annottext">Settings
</span><a href="#local-6989586621681012899"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Settings -&gt; IO Settings
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Settings
</span><a href="#local-6989586621681012899"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-164"></span><span>    </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Settings.IO.html#SettingsError_MissingData"><span class="hs-identifier hs-type">SettingsError_MissingData</span></a></span><span> </span><span id="local-6989586621681012897"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012897"><span class="hs-identifier hs-var">msg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO Settings
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#pgmError"><span class="hs-identifier hs-var">pgmError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012897"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-165"></span><span>    </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Settings.IO.html#SettingsError_BadData"><span class="hs-identifier hs-type">SettingsError_BadData</span></a></span><span> </span><span id="local-6989586621681012895"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012895"><span class="hs-identifier hs-var">msg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO Settings
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#pgmError"><span class="hs-identifier hs-var">pgmError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012895"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span class="hs-comment">{- Note [Windows stack usage]

See: #8870 (and #8834 for related info) and #12186

On Windows, occasionally we need to grow the stack. In order to do
this, we would normally just bump the stack pointer - but there's a
catch on Windows.

If the stack pointer is bumped by more than a single page, then the
pages between the initial pointer and the resulting location must be
properly committed by the Windows virtual memory subsystem. This is
only needed in the event we bump by more than one page (i.e 4097 bytes
or more).

Windows compilers solve this by emitting a call to a special function
called _chkstk, which does this committing of the pages for you.

The reason this was causing a segfault was because due to the fact the
new code generator tends to generate larger functions, we needed more
stack space in GHC itself. In the x86 codegen, we needed approximately
~12kb of stack space in one go, which caused the process to segfault,
as the intervening pages were not committed.

GCC can emit such a check for us automatically but only when the flag
-fstack-check is used.

See https://gcc.gnu.org/onlinedocs/gnat_ugn/Stack-Overflow-Checking.html
for more information.

-}</span><span>
</span><span id="line-197"></span><span>
</span><span id="line-198"></span><span class="annot"><a href="GHC.SysTools.html#copy"><span class="hs-identifier hs-type">copy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-199"></span><span id="copy"><span class="annot"><span class="annottext">copy :: DynFlags -&gt; String -&gt; String -&gt; String -&gt; IO ()
</span><a href="GHC.SysTools.html#copy"><span class="hs-identifier hs-var hs-var">copy</span></a></span></span><span> </span><span id="local-6989586621681012893"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012893"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681012892"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012892"><span class="hs-identifier hs-var">purpose</span></a></span></span><span> </span><span id="local-6989586621681012891"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012891"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681012890"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012890"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; String -&gt; Maybe String -&gt; String -&gt; String -&gt; IO ()
</span><a href="GHC.SysTools.html#copyWithHeader"><span class="hs-identifier hs-var">copyWithHeader</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012893"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012892"><span class="hs-identifier hs-var">purpose</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012891"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012890"><span class="hs-identifier hs-var">to</span></a></span><span>
</span><span id="line-200"></span><span>
</span><span id="line-201"></span><span class="annot"><a href="GHC.SysTools.html#copyWithHeader"><span class="hs-identifier hs-type">copyWithHeader</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-202"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span id="copyWithHeader"><span class="annot"><span class="annottext">copyWithHeader :: DynFlags -&gt; String -&gt; Maybe String -&gt; String -&gt; String -&gt; IO ()
</span><a href="GHC.SysTools.html#copyWithHeader"><span class="hs-identifier hs-var hs-var">copyWithHeader</span></a></span></span><span> </span><span id="local-6989586621681012889"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012889"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681012888"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012888"><span class="hs-identifier hs-var">purpose</span></a></span></span><span> </span><span id="local-6989586621681012887"><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621681012887"><span class="hs-identifier hs-var">maybe_header</span></a></span></span><span> </span><span id="local-6989586621681012886"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012886"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621681012885"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012885"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-204"></span><span>  </span><span class="annot"><span class="annottext">DynFlags -&gt; String -&gt; IO ()
</span><a href="GHC.Utils.Error.html#showPass"><span class="hs-identifier hs-var">showPass</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012889"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012888"><span class="hs-identifier hs-var">purpose</span></a></span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span>  </span><span id="local-6989586621681012883"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012883"><span class="hs-identifier hs-var">hout</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openBinaryFile"><span class="hs-identifier hs-var">openBinaryFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012885"><span class="hs-identifier hs-var">to</span></a></span><span>   </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#WriteMode"><span class="hs-identifier hs-var">WriteMode</span></a></span><span>
</span><span id="line-207"></span><span>  </span><span id="local-6989586621681012880"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012880"><span class="hs-identifier hs-var">hin</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openBinaryFile"><span class="hs-identifier hs-var">openBinaryFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012886"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span>
</span><span id="line-208"></span><span>  </span><span id="local-6989586621681012878"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012878"><span class="hs-identifier hs-var">ls</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012880"><span class="hs-identifier hs-var">hin</span></a></span><span> </span><span class="hs-comment">-- inefficient, but it'll do for now. ToDo: speed up</span><span>
</span><span id="line-209"></span><span>  </span><span class="annot"><span class="annottext">IO () -&gt; (String -&gt; IO ()) -&gt; Maybe String -&gt; IO ()
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; String -&gt; IO ()
</span><a href="#local-6989586621681012875"><span class="hs-identifier hs-var">header</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012883"><span class="hs-identifier hs-var">hout</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621681012887"><span class="hs-identifier hs-var">maybe_header</span></a></span><span>
</span><span id="line-210"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; String -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012883"><span class="hs-identifier hs-var">hout</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012878"><span class="hs-identifier hs-var">ls</span></a></span><span>
</span><span id="line-211"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012883"><span class="hs-identifier hs-var">hout</span></a></span><span>
</span><span id="line-212"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012880"><span class="hs-identifier hs-var">hin</span></a></span><span>
</span><span id="line-213"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-214"></span><span>  </span><span class="hs-comment">-- write the header string in UTF-8.  The header is something like</span><span>
</span><span id="line-215"></span><span>  </span><span class="hs-comment">--   {-# LINE &quot;foo.hs&quot; #-}</span><span>
</span><span id="line-216"></span><span>  </span><span class="hs-comment">-- and we want to make sure a Unicode filename isn't mangled.</span><span>
</span><span id="line-217"></span><span>  </span><span id="local-6989586621681012875"><span class="annot"><span class="annottext">header :: Handle -&gt; String -&gt; IO ()
</span><a href="#local-6989586621681012875"><span class="hs-identifier hs-var hs-var">header</span></a></span></span><span> </span><span id="local-6989586621681012870"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012870"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621681012869"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012869"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-218"></span><span>   </span><span class="annot"><span class="annottext">Handle -&gt; TextEncoding -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-var">hSetEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012870"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="../../base/src/GHC.IO.Encoding.html#utf8"><span class="hs-identifier hs-var">utf8</span></a></span><span>
</span><span id="line-219"></span><span>   </span><span class="annot"><span class="annottext">Handle -&gt; String -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012870"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012869"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-220"></span><span>   </span><span class="annot"><span class="annottext">Handle -&gt; Bool -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetBinaryMode"><span class="hs-identifier hs-var">hSetBinaryMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621681012870"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Support code}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span class="annot"><a href="GHC.SysTools.html#linkDynLib"><span class="hs-identifier hs-type">linkDynLib</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Unit.Types.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-231"></span><span id="linkDynLib"><span class="annot"><span class="annottext">linkDynLib :: DynFlags -&gt; [String] -&gt; [UnitId] -&gt; IO ()
</span><a href="GHC.SysTools.html#linkDynLib"><span class="hs-identifier hs-var hs-var">linkDynLib</span></a></span></span><span> </span><span id="local-6989586621681012865"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012865"><span class="hs-identifier hs-var">dflags0</span></a></span></span><span> </span><span id="local-6989586621681012864"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012864"><span class="hs-identifier hs-var">o_files</span></a></span></span><span> </span><span id="local-6989586621681012863"><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621681012863"><span class="hs-identifier hs-var">dep_packages</span></a></span></span><span>
</span><span id="line-232"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-233"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- This is a rather ugly hack to fix dynamically linked</span><span>
</span><span id="line-234"></span><span>        </span><span class="hs-comment">-- GHC on Windows. If GHC is linked with -threaded, then</span><span>
</span><span id="line-235"></span><span>        </span><span class="hs-comment">-- it links against libHSrts_thr. But if base is linked</span><span>
</span><span id="line-236"></span><span>        </span><span class="hs-comment">-- against libHSrts, then both end up getting loaded,</span><span>
</span><span id="line-237"></span><span>        </span><span class="hs-comment">-- and things go wrong. We therefore link the libraries</span><span>
</span><span id="line-238"></span><span>        </span><span class="hs-comment">-- with the same RTS flags that we link GHC with.</span><span>
</span><span id="line-239"></span><span>        </span><span id="local-6989586621681012862"><span class="annot"><span class="annottext">dflags1 :: DynFlags
</span><a href="#local-6989586621681012862"><span class="hs-identifier hs-var hs-var">dflags1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">PlatformMisc -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformMisc_ghcThreaded"><span class="hs-identifier hs-var hs-var">platformMisc_ghcThreaded</span></a></span><span> </span><span class="annot"><span class="annottext">(PlatformMisc -&gt; Bool) -&gt; PlatformMisc -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; PlatformMisc
</span><a href="GHC.Driver.Session.html#platformMisc"><span class="hs-identifier hs-var hs-var">platformMisc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012865"><span class="hs-identifier hs-var">dflags0</span></a></span><span>
</span><span id="line-240"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Way -&gt; DynFlags -&gt; DynFlags
</span><a href="GHC.Driver.Session.html#addWay%27"><span class="hs-identifier hs-var">addWay'</span></a></span><span> </span><span class="annot"><span class="annottext">Way
</span><a href="GHC.Driver.Ways.html#WayThreaded"><span class="hs-identifier hs-var">WayThreaded</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012865"><span class="hs-identifier hs-var">dflags0</span></a></span><span>
</span><span id="line-241"></span><span>          </span><span class="hs-keyword">else</span><span>                     </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012865"><span class="hs-identifier hs-var">dflags0</span></a></span><span>
</span><span id="line-242"></span><span>        </span><span id="local-6989586621681012857"><span class="annot"><span class="annottext">dflags :: DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">PlatformMisc -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformMisc_ghcDebugged"><span class="hs-identifier hs-var hs-var">platformMisc_ghcDebugged</span></a></span><span> </span><span class="annot"><span class="annottext">(PlatformMisc -&gt; Bool) -&gt; PlatformMisc -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; PlatformMisc
</span><a href="GHC.Driver.Session.html#platformMisc"><span class="hs-identifier hs-var hs-var">platformMisc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012862"><span class="hs-identifier hs-var">dflags1</span></a></span><span>
</span><span id="line-243"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Way -&gt; DynFlags -&gt; DynFlags
</span><a href="GHC.Driver.Session.html#addWay%27"><span class="hs-identifier hs-var">addWay'</span></a></span><span> </span><span class="annot"><span class="annottext">Way
</span><a href="GHC.Driver.Ways.html#WayDebug"><span class="hs-identifier hs-var">WayDebug</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012862"><span class="hs-identifier hs-var">dflags1</span></a></span><span>
</span><span id="line-244"></span><span>          </span><span class="hs-keyword">else</span><span>                  </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012862"><span class="hs-identifier hs-var">dflags1</span></a></span><span>
</span><span id="line-245"></span><span>
</span><span id="line-246"></span><span>        </span><span id="local-6989586621681012854"><span class="annot"><span class="annottext">verbFlags :: [String]
</span><a href="#local-6989586621681012854"><span class="hs-identifier hs-var hs-var">verbFlags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [String]
</span><a href="GHC.Driver.Session.html#getVerbFlags"><span class="hs-identifier hs-var">getVerbFlags</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-247"></span><span>        </span><span id="local-6989586621681012852"><span class="annot"><span class="annottext">o_file :: Maybe String
</span><a href="#local-6989586621681012852"><span class="hs-identifier hs-var hs-var">o_file</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Maybe String
</span><a href="GHC.Driver.Session.html#outputFile"><span class="hs-identifier hs-var hs-var">outputFile</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-248"></span><span>
</span><span id="line-249"></span><span>    </span><span id="local-6989586621681012850"><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012850"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [UnitId] -&gt; IO [UnitInfo]
</span><a href="GHC.Unit.State.html#getPreloadUnitsAnd"><span class="hs-identifier hs-var">getPreloadUnitsAnd</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621681012863"><span class="hs-identifier hs-var">dep_packages</span></a></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012848"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681012848"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-252"></span><span>        </span><span id="local-6989586621681012846"><span class="annot"><span class="annottext">os :: OS
</span><a href="#local-6989586621681012846"><span class="hs-identifier hs-var hs-var">os</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformOS"><span class="hs-identifier hs-var">platformOS</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012848"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-253"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012844"><span class="annot"><span class="annottext">pkg_lib_paths :: [String]
</span><a href="#local-6989586621681012844"><span class="hs-identifier hs-var hs-var">pkg_lib_paths</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [UnitInfo] -&gt; [String]
</span><a href="GHC.Unit.State.html#collectLibraryPaths"><span class="hs-identifier hs-var">collectLibraryPaths</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012850"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-254"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012841"><span class="annot"><span class="annottext">pkg_lib_path_opts :: [String]
</span><a href="#local-6989586621681012841"><span class="hs-identifier hs-var hs-var">pkg_lib_path_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(String -&gt; [String]) -&gt; [String] -&gt; [String]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="#local-6989586621681012839"><span class="hs-identifier hs-var">get_pkg_lib_path_opts</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012844"><span class="hs-identifier hs-var">pkg_lib_paths</span></a></span><span>
</span><span id="line-255"></span><span>        </span><span id="local-6989586621681012839"><span class="annot"><span class="annottext">get_pkg_lib_path_opts :: String -&gt; [String]
</span><a href="#local-6989586621681012839"><span class="hs-identifier hs-var hs-var">get_pkg_lib_path_opts</span></a></span></span><span> </span><span id="local-6989586621681012834"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012834"><span class="hs-identifier hs-var">l</span></a></span></span><span>
</span><span id="line-256"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">OS -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#osElfTarget"><span class="hs-identifier hs-var">osElfTarget</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformOS"><span class="hs-identifier hs-var">platformOS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-257"></span><span>             </span><span class="annot"><span class="annottext">OS -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#osMachOTarget"><span class="hs-identifier hs-var">osMachOTarget</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformOS"><span class="hs-identifier hs-var">platformOS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-258"></span><span>           </span><span class="annot"><span class="annottext">DynFlags -&gt; DynLibLoader
</span><a href="GHC.Driver.Session.html#dynLibLoader"><span class="hs-identifier hs-var hs-var">dynLibLoader</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">DynLibLoader -&gt; DynLibLoader -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">DynLibLoader
</span><a href="GHC.Driver.Session.html#SystemDependent"><span class="hs-identifier hs-var">SystemDependent</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-259"></span><span>           </span><span class="hs-comment">-- Only if we want dynamic libraries</span><span>
</span><span id="line-260"></span><span>           </span><span class="annot"><span class="annottext">Way
</span><a href="GHC.Driver.Ways.html#WayDyn"><span class="hs-identifier hs-var">WayDyn</span></a></span><span> </span><span class="annot"><span class="annottext">Way -&gt; Set Way -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Set Way
</span><a href="GHC.Driver.Session.html#ways"><span class="hs-identifier hs-var hs-var">ways</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-261"></span><span>           </span><span class="hs-comment">-- Only use RPath if we explicitly asked for it</span><span>
</span><span id="line-262"></span><span>           </span><span class="annot"><span class="annottext">DynFlags -&gt; OS -&gt; Bool
</span><a href="GHC.Driver.Session.html#useXLinkerRPath"><span class="hs-identifier hs-var">useXLinkerRPath</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="#local-6989586621681012846"><span class="hs-identifier hs-var">os</span></a></span><span>
</span><span id="line-263"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-L&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012834"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Xlinker&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-rpath&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Xlinker&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012834"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-264"></span><span>              </span><span class="hs-comment">-- See Note [-Xlinker -rpath vs -Wl,-rpath]</span><span>
</span><span id="line-265"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-L&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012834"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-266"></span><span>
</span><span id="line-267"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012823"><span class="annot"><span class="annottext">lib_paths :: [String]
</span><a href="#local-6989586621681012823"><span class="hs-identifier hs-var hs-var">lib_paths</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [String]
</span><a href="GHC.Driver.Session.html#libraryPaths"><span class="hs-identifier hs-var hs-var">libraryPaths</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-268"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012821"><span class="annot"><span class="annottext">lib_path_opts :: [String]
</span><a href="#local-6989586621681012821"><span class="hs-identifier hs-var hs-var">lib_path_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; [String] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-L&quot;</span></span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012823"><span class="hs-identifier hs-var">lib_paths</span></a></span><span>
</span><span id="line-269"></span><span>
</span><span id="line-270"></span><span>    </span><span class="hs-comment">-- We don't want to link our dynamic libs against the RTS package,</span><span>
</span><span id="line-271"></span><span>    </span><span class="hs-comment">-- because the RTS lib comes in several flavours and we want to be</span><span>
</span><span id="line-272"></span><span>    </span><span class="hs-comment">-- able to pick the flavour when a binary is linked.</span><span>
</span><span id="line-273"></span><span>    </span><span class="hs-comment">-- On Windows we need to link the RTS import lib as Windows does</span><span>
</span><span id="line-274"></span><span>    </span><span class="hs-comment">-- not allow undefined symbols.</span><span>
</span><span id="line-275"></span><span>    </span><span class="hs-comment">-- The RTS library path is still added to the library search path</span><span>
</span><span id="line-276"></span><span>    </span><span class="hs-comment">-- above in case the RTS is being explicitly linked in (see #3807).</span><span>
</span><span id="line-277"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012818"><span class="annot"><span class="annottext">pkgs_no_rts :: [UnitInfo]
</span><a href="#local-6989586621681012818"><span class="hs-identifier hs-var hs-var">pkgs_no_rts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="#local-6989586621681012846"><span class="hs-identifier hs-var">os</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-278"></span><span>                      </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSMinGW32"><span class="hs-identifier hs-var">OSMinGW32</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-279"></span><span>                          </span><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012850"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-280"></span><span>                      </span><span class="annot"><span class="annottext">OS
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_LinkRts"><span class="hs-identifier hs-var">Opt_LinkRts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-281"></span><span>                          </span><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012850"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-282"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-283"></span><span>                          </span><span class="annot"><span class="annottext">(UnitInfo -&gt; Bool) -&gt; [UnitInfo] -&gt; [UnitInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnitId -&gt; UnitId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="GHC.Unit.Types.html#rtsUnitId"><span class="hs-identifier hs-var">rtsUnitId</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UnitId -&gt; Bool) -&gt; (UnitInfo -&gt; UnitId) -&gt; UnitInfo -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">UnitInfo -&gt; UnitId
forall compid srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod
-&gt; uid
</span><a href="../../ghc-boot/src/GHC.Unit.Database.html#unitId"><span class="hs-identifier hs-var hs-var">unitId</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012850"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-284"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012810"><span class="annot"><span class="annottext">pkg_link_opts :: [String]
</span><a href="#local-6989586621681012810"><span class="hs-identifier hs-var hs-var">pkg_link_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681012809"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012809"><span class="hs-identifier hs-var">package_hs_libs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681012808"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012808"><span class="hs-identifier hs-var">extra_libs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681012807"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012807"><span class="hs-identifier hs-var">other_flags</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [UnitInfo] -&gt; ([String], [String], [String])
</span><a href="GHC.Unit.State.html#collectLinkOpts"><span class="hs-identifier hs-var">collectLinkOpts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012818"><span class="hs-identifier hs-var">pkgs_no_rts</span></a></span><span>
</span><span id="line-285"></span><span>                        </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012809"><span class="hs-identifier hs-var">package_hs_libs</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012808"><span class="hs-identifier hs-var">extra_libs</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012807"><span class="hs-identifier hs-var">other_flags</span></a></span><span>
</span><span id="line-286"></span><span>
</span><span id="line-287"></span><span>        </span><span class="hs-comment">-- probably _stub.o files</span><span>
</span><span id="line-288"></span><span>        </span><span class="hs-comment">-- and last temporary shared object file</span><span>
</span><span id="line-289"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012805"><span class="annot"><span class="annottext">extra_ld_inputs :: [Option]
</span><a href="#local-6989586621681012805"><span class="hs-identifier hs-var hs-var">extra_ld_inputs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [Option]
</span><a href="GHC.Driver.Session.html#ldInputs"><span class="hs-identifier hs-var hs-var">ldInputs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-290"></span><span>
</span><span id="line-291"></span><span>    </span><span class="hs-comment">-- frameworks</span><span>
</span><span id="line-292"></span><span>    </span><span id="local-6989586621681012803"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012803"><span class="hs-identifier hs-var">pkg_framework_opts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform -&gt; [UnitId] -&gt; IO [String]
</span><a href="GHC.SysTools.html#getUnitFrameworkOpts"><span class="hs-identifier hs-var">getUnitFrameworkOpts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012848"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-293"></span><span>                                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(UnitInfo -&gt; UnitId) -&gt; [UnitInfo] -&gt; [UnitId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">UnitInfo -&gt; UnitId
forall compid srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod
-&gt; uid
</span><a href="../../ghc-boot/src/GHC.Unit.Database.html#unitId"><span class="hs-identifier hs-var hs-var">unitId</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitInfo]
</span><a href="#local-6989586621681012850"><span class="hs-identifier hs-var">pkgs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012802"><span class="annot"><span class="annottext">framework_opts :: [String]
</span><a href="#local-6989586621681012802"><span class="hs-identifier hs-var hs-var">framework_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform -&gt; [String]
</span><a href="GHC.SysTools.html#getFrameworkOpts"><span class="hs-identifier hs-var">getFrameworkOpts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012848"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-295"></span><span>
</span><span id="line-296"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="#local-6989586621681012846"><span class="hs-identifier hs-var">os</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-297"></span><span>        </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSMinGW32"><span class="hs-identifier hs-var">OSMinGW32</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-298"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------</span><span>
</span><span id="line-299"></span><span>            </span><span class="hs-comment">-- Making a DLL</span><span>
</span><span id="line-300"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------</span><span>
</span><span id="line-301"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012801"><span class="annot"><span class="annottext">output_fn :: String
</span><a href="#local-6989586621681012801"><span class="hs-identifier hs-var hs-var">output_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621681012852"><span class="hs-identifier hs-var">o_file</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-302"></span><span>                            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681012800"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012800"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012800"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-303"></span><span>                            </span><span class="annot"><span class="annottext">Maybe String
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;HSdll.dll&quot;</span></span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span>            </span><span class="annot"><span class="annottext">DynFlags -&gt; [Option] -&gt; IO ()
</span><a href="GHC.SysTools.Tasks.html#runLink"><span class="hs-identifier hs-var">runLink</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-306"></span><span>                    </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012854"><span class="hs-identifier hs-var">verbFlags</span></a></span><span>
</span><span id="line-307"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-o&quot;</span></span><span>
</span><span id="line-308"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#FileOption"><span class="hs-identifier hs-var">FileOption</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012801"><span class="hs-identifier hs-var">output_fn</span></a></span><span>
</span><span id="line-309"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-shared&quot;</span></span><span>
</span><span id="line-310"></span><span>                    </span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-311"></span><span>                    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#FileOption"><span class="hs-identifier hs-var">FileOption</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--out-implib=&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012801"><span class="hs-identifier hs-var">output_fn</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;.a&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_SharedImplib"><span class="hs-identifier hs-var">Opt_SharedImplib</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-313"></span><span>                    </span><span class="hs-special">]</span><span>
</span><span id="line-314"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#FileOption"><span class="hs-identifier hs-var">FileOption</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012864"><span class="hs-identifier hs-var">o_files</span></a></span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span>                 </span><span class="hs-comment">-- Permit the linker to auto link _symbol to _imp_symbol</span><span>
</span><span id="line-317"></span><span>                 </span><span class="hs-comment">-- This lets us link against DLLs without needing an &quot;import library&quot;</span><span>
</span><span id="line-318"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--enable-auto-import&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-319"></span><span>
</span><span id="line-320"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621681012805"><span class="hs-identifier hs-var">extra_ld_inputs</span></a></span><span>
</span><span id="line-321"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-322"></span><span>                    </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012821"><span class="hs-identifier hs-var">lib_path_opts</span></a></span><span>
</span><span id="line-323"></span><span>                 </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012841"><span class="hs-identifier hs-var">pkg_lib_path_opts</span></a></span><span>
</span><span id="line-324"></span><span>                 </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012810"><span class="hs-identifier hs-var">pkg_link_opts</span></a></span><span>
</span><span id="line-325"></span><span>                </span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-326"></span><span>        </span><span class="annot"><span class="annottext">OS
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="#local-6989586621681012846"><span class="hs-identifier hs-var">os</span></a></span><span> </span><span class="annot"><span class="annottext">OS -&gt; OS -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSDarwin"><span class="hs-identifier hs-var">OSDarwin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-327"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------------</span><span>
</span><span id="line-328"></span><span>            </span><span class="hs-comment">-- Making a darwin dylib</span><span>
</span><span id="line-329"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------------</span><span>
</span><span id="line-330"></span><span>            </span><span class="hs-comment">-- About the options used for Darwin:</span><span>
</span><span id="line-331"></span><span>            </span><span class="hs-comment">-- -dynamiclib</span><span>
</span><span id="line-332"></span><span>            </span><span class="hs-comment">--   Apple's way of saying -shared</span><span>
</span><span id="line-333"></span><span>            </span><span class="hs-comment">-- -undefined dynamic_lookup:</span><span>
</span><span id="line-334"></span><span>            </span><span class="hs-comment">--   Without these options, we'd have to specify the correct</span><span>
</span><span id="line-335"></span><span>            </span><span class="hs-comment">--   dependencies for each of the dylibs. Note that we could</span><span>
</span><span id="line-336"></span><span>            </span><span class="hs-comment">--   (and should) do without this for all libraries except</span><span>
</span><span id="line-337"></span><span>            </span><span class="hs-comment">--   the RTS; all we need to do is to pass the correct</span><span>
</span><span id="line-338"></span><span>            </span><span class="hs-comment">--   HSfoo_dyn.dylib files to the link command.</span><span>
</span><span id="line-339"></span><span>            </span><span class="hs-comment">--   This feature requires Mac OS X 10.3 or later; there is</span><span>
</span><span id="line-340"></span><span>            </span><span class="hs-comment">--   a similar feature, -flat_namespace -undefined suppress,</span><span>
</span><span id="line-341"></span><span>            </span><span class="hs-comment">--   which works on earlier versions, but it has other</span><span>
</span><span id="line-342"></span><span>            </span><span class="hs-comment">--   disadvantages.</span><span>
</span><span id="line-343"></span><span>            </span><span class="hs-comment">-- -single_module</span><span>
</span><span id="line-344"></span><span>            </span><span class="hs-comment">--   Build the dynamic library as a single &quot;module&quot;, i.e. no</span><span>
</span><span id="line-345"></span><span>            </span><span class="hs-comment">--   dynamic binding nonsense when referring to symbols from</span><span>
</span><span id="line-346"></span><span>            </span><span class="hs-comment">--   within the library. The NCG assumes that this option is</span><span>
</span><span id="line-347"></span><span>            </span><span class="hs-comment">--   specified (on i386, at least).</span><span>
</span><span id="line-348"></span><span>            </span><span class="hs-comment">-- -install_name</span><span>
</span><span id="line-349"></span><span>            </span><span class="hs-comment">--   Mac OS/X stores the path where a dynamic library is (to</span><span>
</span><span id="line-350"></span><span>            </span><span class="hs-comment">--   be) installed in the library itself.  It's called the</span><span>
</span><span id="line-351"></span><span>            </span><span class="hs-comment">--   &quot;install name&quot; of the library. Then any library or</span><span>
</span><span id="line-352"></span><span>            </span><span class="hs-comment">--   executable that links against it before it's installed</span><span>
</span><span id="line-353"></span><span>            </span><span class="hs-comment">--   will search for it in its ultimate install location.</span><span>
</span><span id="line-354"></span><span>            </span><span class="hs-comment">--   By default we set the install name to the absolute path</span><span>
</span><span id="line-355"></span><span>            </span><span class="hs-comment">--   at build time, but it can be overridden by the</span><span>
</span><span id="line-356"></span><span>            </span><span class="hs-comment">--   -dylib-install-name option passed to ghc. Cabal does</span><span>
</span><span id="line-357"></span><span>            </span><span class="hs-comment">--   this.</span><span>
</span><span id="line-358"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------------</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012794"><span class="annot"><span class="annottext">output_fn :: String
</span><a href="#local-6989586621681012794"><span class="hs-identifier hs-var hs-var">output_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621681012852"><span class="hs-identifier hs-var">o_file</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681012793"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012793"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012793"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;a.out&quot;</span></span><span class="hs-special">;</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-361"></span><span>
</span><span id="line-362"></span><span>            </span><span id="local-6989586621681012792"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012792"><span class="hs-identifier hs-var">instName</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Maybe String
</span><a href="GHC.Driver.Session.html#dylibInstallName"><span class="hs-identifier hs-var hs-var">dylibInstallName</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-363"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681012790"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012790"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012790"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-364"></span><span>                </span><span class="annot"><span class="annottext">Maybe String
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; IO String) -&gt; String -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;@rpath&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
</span><a href="../../filepath/src/System.FilePath.Windows.html#combine"><span class="hs-operator hs-var">`combine`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="../../filepath/src/System.FilePath.Windows.html#takeFileName"><span class="hs-identifier hs-var">takeFileName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012794"><span class="hs-identifier hs-var">output_fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span>            </span><span class="annot"><span class="annottext">DynFlags -&gt; [Option] -&gt; IO ()
</span><a href="GHC.SysTools.Tasks.html#runLink"><span class="hs-identifier hs-var">runLink</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-366"></span><span>                    </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012854"><span class="hs-identifier hs-var">verbFlags</span></a></span><span>
</span><span id="line-367"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-dynamiclib&quot;</span></span><span>
</span><span id="line-368"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-o&quot;</span></span><span>
</span><span id="line-369"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#FileOption"><span class="hs-identifier hs-var">FileOption</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012794"><span class="hs-identifier hs-var">output_fn</span></a></span><span>
</span><span id="line-370"></span><span>                    </span><span class="hs-special">]</span><span>
</span><span id="line-371"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012864"><span class="hs-identifier hs-var">o_files</span></a></span><span>
</span><span id="line-372"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-undefined&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-373"></span><span>                      </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dynamic_lookup&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-374"></span><span>                      </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-single_module&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-375"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformArch"><span class="hs-identifier hs-var">platformArch</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012848"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Arch -&gt; [Arch] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#ArchX86_64"><span class="hs-identifier hs-var">ArchX86_64</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#ArchAArch64"><span class="hs-identifier hs-var">ArchAArch64</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-376"></span><span>                     </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-377"></span><span>                     </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,-read_only_relocs,suppress&quot;</span></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-378"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-install_name&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012792"><span class="hs-identifier hs-var">instName</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-379"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012821"><span class="hs-identifier hs-var">lib_path_opts</span></a></span><span>
</span><span id="line-380"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621681012805"><span class="hs-identifier hs-var">extra_ld_inputs</span></a></span><span>
</span><span id="line-381"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012802"><span class="hs-identifier hs-var">framework_opts</span></a></span><span>
</span><span id="line-382"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012841"><span class="hs-identifier hs-var">pkg_lib_path_opts</span></a></span><span>
</span><span id="line-383"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012810"><span class="hs-identifier hs-var">pkg_link_opts</span></a></span><span>
</span><span id="line-384"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012803"><span class="hs-identifier hs-var">pkg_framework_opts</span></a></span><span>
</span><span id="line-385"></span><span>                 </span><span class="hs-comment">-- dead_strip_dylibs, will remove unused dylibs, and thus save</span><span>
</span><span id="line-386"></span><span>                 </span><span class="hs-comment">-- space in the load commands. The -headerpad is necessary so</span><span>
</span><span id="line-387"></span><span>                 </span><span class="hs-comment">-- that we can inject more @rpath's later for the leftover</span><span>
</span><span id="line-388"></span><span>                 </span><span class="hs-comment">-- libraries in the runInjectRpaths phase below.</span><span>
</span><span id="line-389"></span><span>                 </span><span class="hs-comment">--</span><span>
</span><span id="line-390"></span><span>                 </span><span class="hs-comment">-- See Note [Dynamic linking on macOS]</span><span>
</span><span id="line-391"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,-dead_strip_dylibs&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,-headerpad,8000&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-392"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>            </span><span class="annot"><span class="annottext">DynFlags -&gt; [String] -&gt; String -&gt; IO ()
</span><a href="GHC.SysTools.Tasks.html#runInjectRPaths"><span class="hs-identifier hs-var">runInjectRPaths</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012844"><span class="hs-identifier hs-var">pkg_lib_paths</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012794"><span class="hs-identifier hs-var">output_fn</span></a></span><span>
</span><span id="line-394"></span><span>        </span><span class="annot"><span class="annottext">OS
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-395"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------------</span><span>
</span><span id="line-396"></span><span>            </span><span class="hs-comment">-- Making a DSO</span><span>
</span><span id="line-397"></span><span>            </span><span class="hs-comment">-------------------------------------------------------------------</span><span>
</span><span id="line-398"></span><span>
</span><span id="line-399"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012782"><span class="annot"><span class="annottext">output_fn :: String
</span><a href="#local-6989586621681012782"><span class="hs-identifier hs-var hs-var">output_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="#local-6989586621681012852"><span class="hs-identifier hs-var">o_file</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681012781"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012781"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012781"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe String
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;a.out&quot;</span></span><span class="hs-special">;</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-400"></span><span>                </span><span id="local-6989586621681012780"><span class="annot"><span class="annottext">unregisterised :: Bool
</span><a href="#local-6989586621681012780"><span class="hs-identifier hs-var hs-var">unregisterised</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformUnregisterised"><span class="hs-identifier hs-var hs-var">platformUnregisterised</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-401"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681012778"><span class="annot"><span class="annottext">bsymbolicFlag :: [String]
</span><a href="#local-6989586621681012778"><span class="hs-identifier hs-var hs-var">bsymbolicFlag</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- we need symbolic linking to resolve</span><span>
</span><span id="line-402"></span><span>                                </span><span class="hs-comment">-- non-PIC intra-package-relocations for</span><span>
</span><span id="line-403"></span><span>                                </span><span class="hs-comment">-- performance (where symbolic linking works)</span><span>
</span><span id="line-404"></span><span>                                </span><span class="hs-comment">-- See Note [-Bsymbolic assumptions by GHC]</span><span>
</span><span id="line-405"></span><span>                                </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,-Bsymbolic&quot;</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681012780"><span class="hs-identifier hs-var">unregisterised</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-406"></span><span>
</span><span id="line-407"></span><span>            </span><span class="annot"><span class="annottext">DynFlags -&gt; [Option] -&gt; IO ()
</span><a href="GHC.SysTools.Tasks.html#runLink"><span class="hs-identifier hs-var">runLink</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-408"></span><span>                    </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012854"><span class="hs-identifier hs-var">verbFlags</span></a></span><span>
</span><span id="line-409"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="GHC.SysTools.html#libmLinkOpts"><span class="hs-identifier hs-var">libmLinkOpts</span></a></span><span>
</span><span id="line-410"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-o&quot;</span></span><span>
</span><span id="line-411"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#FileOption"><span class="hs-identifier hs-var">FileOption</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012782"><span class="hs-identifier hs-var">output_fn</span></a></span><span>
</span><span id="line-412"></span><span>                    </span><span class="hs-special">]</span><span>
</span><span id="line-413"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012864"><span class="hs-identifier hs-var">o_files</span></a></span><span>
</span><span id="line-414"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-shared&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-415"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012778"><span class="hs-identifier hs-var">bsymbolicFlag</span></a></span><span>
</span><span id="line-416"></span><span>                    </span><span class="hs-comment">-- Set the library soname. We use -h rather than -soname as</span><span>
</span><span id="line-417"></span><span>                    </span><span class="hs-comment">-- Solaris 10 doesn't support the latter:</span><span>
</span><span id="line-418"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,-h,&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="../../filepath/src/System.FilePath.Windows.html#takeFileName"><span class="hs-identifier hs-var">takeFileName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012782"><span class="hs-identifier hs-var">output_fn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-419"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621681012805"><span class="hs-identifier hs-var">extra_ld_inputs</span></a></span><span>
</span><span id="line-420"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012821"><span class="hs-identifier hs-var">lib_path_opts</span></a></span><span>
</span><span id="line-421"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012841"><span class="hs-identifier hs-var">pkg_lib_path_opts</span></a></span><span>
</span><span id="line-422"></span><span>                 </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012810"><span class="hs-identifier hs-var">pkg_link_opts</span></a></span><span>
</span><span id="line-423"></span><span>              </span><span class="hs-special">)</span><span>
</span><span id="line-424"></span><span>
</span><span id="line-425"></span><span class="hs-comment">-- | Some platforms require that we explicitly link against @libm@ if any</span><span>
</span><span id="line-426"></span><span class="hs-comment">-- math-y things are used (which we assume to include all programs). See #14022.</span><span>
</span><span id="line-427"></span><span class="annot"><a href="GHC.SysTools.html#libmLinkOpts"><span class="hs-identifier hs-type">libmLinkOpts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-type">Option</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-428"></span><span id="libmLinkOpts"><span class="annot"><span class="annottext">libmLinkOpts :: [Option]
</span><a href="GHC.SysTools.html#libmLinkOpts"><span class="hs-identifier hs-var hs-var">libmLinkOpts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span class="hs-cpp">
#if defined(HAVE_LIBM)
</span><span>  </span><span class="hs-special">[</span><span class="hs-identifier">Option</span><span> </span><span class="hs-string">&quot;-lm&quot;</span><span class="hs-special">]</span><span class="hs-cpp">
#else
</span><span>  </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-435"></span><span class="annot"><a href="GHC.SysTools.html#getUnitFrameworkOpts"><span class="hs-identifier hs-type">getUnitFrameworkOpts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Unit.Types.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-436"></span><span id="getUnitFrameworkOpts"><span class="annot"><span class="annottext">getUnitFrameworkOpts :: DynFlags -&gt; Platform -&gt; [UnitId] -&gt; IO [String]
</span><a href="GHC.SysTools.html#getUnitFrameworkOpts"><span class="hs-identifier hs-var hs-var">getUnitFrameworkOpts</span></a></span></span><span> </span><span id="local-6989586621681012776"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012776"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681012775"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012775"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681012774"><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621681012774"><span class="hs-identifier hs-var">dep_packages</span></a></span></span><span>
</span><span id="line-437"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformUsesFrameworks"><span class="hs-identifier hs-var">platformUsesFrameworks</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012775"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-438"></span><span>    </span><span id="local-6989586621681012772"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012772"><span class="hs-identifier hs-var">pkg_framework_path_opts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-439"></span><span>        </span><span id="local-6989586621681012771"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012771"><span class="hs-identifier hs-var">pkg_framework_paths</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [UnitId] -&gt; IO [String]
</span><a href="GHC.Unit.State.html#getUnitFrameworkPath"><span class="hs-identifier hs-var">getUnitFrameworkPath</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012776"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621681012774"><span class="hs-identifier hs-var">dep_packages</span></a></span><span>
</span><span id="line-440"></span><span>        </span><span class="annot"><span class="annottext">[String] -&gt; IO [String]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; IO [String]) -&gt; [String] -&gt; IO [String]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; [String] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-F&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012771"><span class="hs-identifier hs-var">pkg_framework_paths</span></a></span><span>
</span><span id="line-441"></span><span>
</span><span id="line-442"></span><span>    </span><span id="local-6989586621681012769"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012769"><span class="hs-identifier hs-var">pkg_framework_opts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-443"></span><span>        </span><span id="local-6989586621681012768"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012768"><span class="hs-identifier hs-var">pkg_frameworks</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [UnitId] -&gt; IO [String]
</span><a href="GHC.Unit.State.html#getUnitFrameworks"><span class="hs-identifier hs-var">getUnitFrameworks</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012776"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621681012774"><span class="hs-identifier hs-var">dep_packages</span></a></span><span>
</span><span id="line-444"></span><span>        </span><span class="annot"><span class="annottext">[String] -&gt; IO [String]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; IO [String]) -&gt; [String] -&gt; IO [String]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[[String]] -&gt; [String]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-framework&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012765"><span class="hs-identifier hs-var">fw</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681012765"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012765"><span class="hs-identifier hs-var">fw</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012768"><span class="hs-identifier hs-var">pkg_frameworks</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-445"></span><span>
</span><span id="line-446"></span><span>    </span><span class="annot"><span class="annottext">[String] -&gt; IO [String]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012772"><span class="hs-identifier hs-var">pkg_framework_path_opts</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012769"><span class="hs-identifier hs-var">pkg_framework_opts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-447"></span><span>
</span><span id="line-448"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; IO [String]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-449"></span><span>
</span><span id="line-450"></span><span class="annot"><a href="GHC.SysTools.html#getFrameworkOpts"><span class="hs-identifier hs-type">getFrameworkOpts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-451"></span><span id="getFrameworkOpts"><span class="annot"><span class="annottext">getFrameworkOpts :: DynFlags -&gt; Platform -&gt; [String]
</span><a href="GHC.SysTools.html#getFrameworkOpts"><span class="hs-identifier hs-var hs-var">getFrameworkOpts</span></a></span></span><span> </span><span id="local-6989586621681012764"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012764"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681012763"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012763"><span class="hs-identifier hs-var">platform</span></a></span></span><span>
</span><span id="line-452"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Bool
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformUsesFrameworks"><span class="hs-identifier hs-var">platformUsesFrameworks</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681012763"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012762"><span class="hs-identifier hs-var">framework_path_opts</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012761"><span class="hs-identifier hs-var">framework_opts</span></a></span><span>
</span><span id="line-453"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-454"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-455"></span><span>    </span><span id="local-6989586621681012760"><span class="annot"><span class="annottext">framework_paths :: [String]
</span><a href="#local-6989586621681012760"><span class="hs-identifier hs-var hs-var">framework_paths</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [String]
</span><a href="GHC.Driver.Session.html#frameworkPaths"><span class="hs-identifier hs-var hs-var">frameworkPaths</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012764"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-456"></span><span>    </span><span id="local-6989586621681012762"><span class="annot"><span class="annottext">framework_path_opts :: [String]
</span><a href="#local-6989586621681012762"><span class="hs-identifier hs-var hs-var">framework_path_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; [String] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-F&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012760"><span class="hs-identifier hs-var">framework_paths</span></a></span><span>
</span><span id="line-457"></span><span>
</span><span id="line-458"></span><span>    </span><span id="local-6989586621681012758"><span class="annot"><span class="annottext">frameworks :: [String]
</span><a href="#local-6989586621681012758"><span class="hs-identifier hs-var hs-var">frameworks</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [String]
</span><a href="GHC.Driver.Session.html#cmdlineFrameworks"><span class="hs-identifier hs-var hs-var">cmdlineFrameworks</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681012764"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-459"></span><span>    </span><span class="hs-comment">-- reverse because they're added in reverse order from the cmd line:</span><span>
</span><span id="line-460"></span><span>    </span><span id="local-6989586621681012761"><span class="annot"><span class="annottext">framework_opts :: [String]
</span><a href="#local-6989586621681012761"><span class="hs-identifier hs-var hs-var">framework_opts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[[String]] -&gt; [String]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-framework&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012755"><span class="hs-identifier hs-var">fw</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-461"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681012755"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681012755"><span class="hs-identifier hs-var">fw</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681012758"><span class="hs-identifier hs-var">frameworks</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-462"></span><span>
</span><span id="line-463"></span><span class="hs-comment">{-
Note [-Bsymbolic assumptions by GHC]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GHC has a few assumptions about interaction of relocations in NCG and linker:

1. -Bsymbolic resolves internal references when the shared library is linked,
   which is important for performance.
2. When there is a reference to data in a shared library from the main program,
   the runtime linker relocates the data object into the main program using an
   R_*_COPY relocation.
3. If we used -Bsymbolic, then this results in multiple copies of the data
   object, because some references have already been resolved to point to the
   original instance. This is bad!

We work around [3.] for native compiled code by avoiding the generation of
R_*_COPY relocations.

Unregisterised compiler can't evade R_*_COPY relocations easily thus we disable
-Bsymbolic linking there.

See related tickets: #4210, #15338
-}</span><span>
</span><span id="line-486"></span></pre></body></html>